package com.whynot.frame.designMode.proxy.jdkdynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * jdk的动态代理模式
 * @author chenyao
 * 
 * 缺点：只适用于接口
 */
public class UserServiceDynamicProxy implements InvocationHandler{

	private Object obj;
	
	public UserServiceDynamicProxy(Object obj) {
		super();
		this.obj = obj;
	}

	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("报道");
		method.invoke(obj, args);
		System.out.println("去宿舍");
		return null;
	}
	
}
